home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_12 / taylor / gpib.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-18  |  944 b   |  37 lines

  1. // gpib.cpp
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <iostream.h>
  5. #include <dos.h>
  6. #include "gpibio.h"   // Defines GPIB STREAM Classes
  7.  
  8. gpibout gout(5,0);   // GPIB output device 5 stream on gpib board 0
  9. gpibin  gin(5,0);    // GPIB input device 5 stream on gpib board 0
  10.  
  11. void main(void) // Example of using GPIB streams
  12. {
  13.     char buffer[128];
  14.  
  15.     // Get identity
  16.     if(!(gout <<"*idn?" << endl))
  17.     {
  18.        cerr << "Can't output *idn?" << endl;
  19.        exit(1);
  20.     }
  21.     if(!(gin >> buffer))
  22.     {
  23.        cerr << "No *idn? response" << endl;
  24.        exit(1);
  25.     }
  26.     cout << buffer << endl;
  27.  
  28.     // Request, get and display 10 frequency measurements
  29.     for (int i=0; i<10; i++)
  30.     {
  31.          gout <<":MEAS:FREQ?;:SYST:TIME?" << endl;
  32.          gin >> freq >> hr >> min >> sec;
  33.          cout << "Frequency =  " << freq;
  34.          cout << ' '  << hr << ':' << min << ':' << sec << endl;
  35.     }
  36. }
  37.